package com.blrs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.blrs.common.annotation.Anonymous;
import com.blrs.service.platform.IPlatformFunctionService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.blrs.common.annotation.Log;
import com.blrs.common.core.controller.BaseController;
import com.blrs.common.core.domain.AjaxResult;
import com.blrs.common.enums.BusinessType;
import com.blrs.domain.PlatformFunction;
import com.blrs.common.utils.poi.ExcelUtil;
import com.blrs.common.core.page.TableDataInfo;

/**
 * 平台功能Controller
 * 
 * @author ruoyi
 * @date 2025-05-12
 */
@RestController
@RequestMapping("/platform/function")
public class PlatformFunctionController extends BaseController
{
    @Autowired
    private IPlatformFunctionService platformFunctionService;

    /**
     * 查询平台功能列表
     */
    @GetMapping("/list")
    @Anonymous
    public TableDataInfo list(PlatformFunction platformFunction)
    {
        startPage();
        List<PlatformFunction> list = platformFunctionService.selectPlatformFunctionList(platformFunction);
        return getDataTable(list);
    }

    /**
     * 导出平台功能列表
     */
    @Log(title = "平台功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlatformFunction platformFunction)
    {
        List<PlatformFunction> list = platformFunctionService.selectPlatformFunctionList(platformFunction);
        ExcelUtil<PlatformFunction> util = new ExcelUtil<PlatformFunction>(PlatformFunction.class);
        util.exportExcel(response, list, "平台功能数据");
    }

    /**
     * 获取平台功能详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(platformFunctionService.selectPlatformFunctionById(id));
    }

    /**
     * 新增平台功能
     */
    @Log(title = "平台功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformFunction platformFunction)
    {
        return toAjax(platformFunctionService.insertPlatformFunction(platformFunction));
    }

    /**
     * 修改平台功能
     */
    @Log(title = "平台功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformFunction platformFunction)
    {
        return toAjax(platformFunctionService.updatePlatformFunction(platformFunction));
    }

    /**
     * 删除平台功能
     */
    @Log(title = "平台功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(platformFunctionService.deletePlatformFunctionByIds(ids));
    }
    /**
     * 公共端查询平台功能
     */
    @Anonymous
    @GetMapping("/public/list")
    public List<List<PlatformFunction>> publicList(PlatformFunction platformFunction) {
        return platformFunctionService.selectPlatformFunctionListByPublic(platformFunction);
    }
}
